#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100005;
int nums[MAXN];
int used[MAXN] = {};
int beat[MAXN] = {};
int d;
int n = 0;
int cnt = 0;
int sum = 0;
int endd = 0;
int con;

int a1,a2,a3,a4,a5;

inline int read()
{
    int x = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
        {
            f = -1;
            ch = getchar();
        }
    }
    while(ch >= '0' && ch <= '9')
    {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

void fun()
{
    con = 0;
    if(endd > 999)
    {
        return;
    }
    for(int i = 1;i <= n;i++)
    {
       if(beat[i] == 0 && used[i] == 0)
       {
           con = 1;
       }
    }
    if(con == 0)
    {
        if(d > sum)
        {
            sum = d;
        }
        else
        {
            endd++;
        }
        return;
    }


    for(int i = 1;i <= n;i++)
    {
        if(beat[i] == 0 && used[i] == 0)
        {
            for(int j= 1;j <= i + 1;j++)
            {
                if(beat[j] == 1 || i == j)
                {
                    continue;
                }

                used[i] = 1;
                cnt++;
                if(nums[i] > nums[j])
                {
                    beat[j] = 1;
                    d++;
                }
                fun();

                if(nums[i] > nums[j])
                {
                    beat[j] = 0;
                    d--;
                }
                cnt--;
                used[i] = 0;
            }
        }
    }
}

int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);

    int judge = 0;
    n = read();
    for(int i = 1;i <= n;i++)
    {
        nums[i] = read();
        if(nums[i] != 1 && nums[i] != 2)
        {
            judge = 1;
        }
    }
    if(judge == 0)
    {
        int num1 = 0;
        int num2 = 0;
        int ans = 0;
        for(int i = 1;i <= n;i++)
        {
            if(nums[i] == 1)
            {

                num1++;
            }
            else
            {
                num2++;
            }
        }

        if(num2 >= num1)
        {
            ans = n - num1;
        }
        else
        {
            ans = n - num2;
        }
        cout << ans << endl;
    }
    else
    {

        sort(nums + 1,nums + n + 1);
        fun();

        int res = n - sum;

        printf("%d",res);
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
